<template>
  <!-- 订单统计 -->
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单统计</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <!-- 搜索区域 -->
    <el-card>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容" v-model="queryshop.query"
          clearable
          @clear="getOrderList">
          <el-button
          slot="append"
          icon="el-icon-search"
          @click="getOrderList"
          clearable></el-button>
          </el-input>
        </el-col>
      </el-row>
    </el-card>

    <!-- table表格 -->
    <el-card>
    <el-table
      :data="orderlist"
      stripe
      style="width: 100%">
      <el-table-column
        prop="order_state" label="状态" align="center">
        <template #default="{row}">
          {{status[state.indexOf(row.order_state)]}}
        </template>
      </el-table-column>
      <el-table-column
        prop="count" label="数量" align="center">
      </el-table-column>
    </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 查询参数对象
      queryshop: {
        query: '',
        pageNum: 1,
        pageSize: 2
      },
      // 列表
      orderlist: [],
      status: [
        '待支付',
        '待自提',
        '待配送',
        '待发货',
        '已收货',
        '已取消',
        '售后退款'
      ],
      state: [
        'unpaid',
        'untake',
        'undelivery',
        'unsend',
        'take',
        'refund',
        'cancel'
      ]

    }
  },
  created () {
    this.getOrderList()
  },
  mounted () {

  },
  methods: {
    // 获取订单统计列表
    async getOrderList () {
      const { data: res } = await this.$http.get('/goods-order/state', { params: this.queryshop })
      console.log(res)
      if (res.meta.status !== 200) return this.$message.error('获取店铺列表失败')
      this.orderlist = res.data
    },
    // 监听添加商铺对话框的关闭事件
    addDialogClosed () {
      this.$refs.addFormRef.resetFields()
    }

  }
}
</script>

<style scoped lang="less">

</style>
